<!-- 批量分配医生 -->
<template>
  <el-dialog
    :title="title"
    :visible.sync="open"
    width="500px"
    append-to-body
    :close-on-click-modal="false"
    @close="closeModal"
  >
    <SelectExpert :defaultValue.sync="form.expertId" :prescriptionFlag="1" />
    <div class="mt-15 color9 mx-20">
      为机构分配审证审方的医生后，医生可在小程序中查看对应机构需审核的处方单。
    </div>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="submitForm">保 存</el-button>
      <el-button @click="open = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { allotExpert } from "@/api/dpReview";
import SelectExpert from "@/views/expert/expert/selectExpert";

export default {
  components: {
    SelectExpert,
  },
  data() {
    return {
      title: "分配审证审方医生",
      open: false,
      form: {
        ids: "",
        expertId: "",
      },
    };
  },
  methods: {
    openModal(ids, expertId) {
      this.open = true;
      this.form.ids = ids;
      this.form.expertId = expertId || "";
    },
    closeModal() {
      Object.assign(this.$data, this.$options.data()); // 存在自定义校验规则不能重置data
    },
    submitForm() {
      const that = this;
      allotExpert(this.form).then((res) => {
        that.$message.success("分配成功");
        that.$emit("refresh");
        that.closeModal();
      });
    },
  },
};
</script>

<style lang="scss" scoped></style>
